<template>
    <div class="dynamicDriverDiv">
        <el-row>
            <el-col :span="24"
                    title="操作目标"
                    style="padding:5px;width: auto; font-size:16px;font-weight:bold;">操作目标</el-col>
        </el-row>
        <el-form :model="dynaFormData"
                 ref="dynaFormRef"
                 label-width="100px"
                 label-position="left"
                 :rules="saveDynaFormRules">
            <el-row>
                <!-- 动因数据表 -->
                <el-col :span="5"
                        :offset="1">
                    <el-form-item label="动因数据表: "
                                  prop="pubPhysicaltableId"
                                  required>
                        <el-select v-model="dynaFormData.pubPhysicaltableId"
                                   @change="tabelNameEnChange"
                                   placeholder="请选择表">
                            <el-option v-for="item in foundTableData"
                                       :key="item.tableId"
                                       :label="item.tableNameCn+'--'+item.tableNameEn"
                                       :value="item.tableNameEn"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <!-- 动因数值字段 -->
                <el-col :span="5"
                        :offset="1">
                    <el-form-item label="动因数值字段: "
                                  prop="pubPhysicalcolumnId"
                                  required>
                        <el-select v-model="dynaFormData.pubPhysicalcolumnId"
                                   placeholder="请选择字段">
                            <el-option v-for="item in foundTableData"
                                       :key="item.tableId"
                                       :label="item.tableNameCn+'--'+item.tableNameEn"
                                       :value="item.tableNameEn"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <!-- 动因类别 -->
                <el-col :span="6"></el-col>
                <!-- 求占比 -->
                <el-col :span="6"></el-col>
            </el-row>
        </el-form>
    </div>
</template>

<script>
import { publicManage_dat } from '@/api/index'
export default {
    props: {},
    data() {
        return {
            //动因数据规则
            saveDynaFormRules: {},
            //动因保存数据
            dynaFormData: {},
            //金融工具表数据
            foundTableData: [],
            //动因类别是否展示
            drverTypeFlag:false,
        }
    },
    created() {
        this.queryFoundTableList()
    },
    methods: {
        //查询金融工具表数据
        queryFoundTableList() {
            let dataSearch = {
                isModule: '0',
                moduleCode: 'ca'
            }

            publicManage_dat.fundToolTableQueryListCa(dataSearch).then(res => {
                if (res.code == 200) {
                    console.log(res.datas, '金融工具表数据')
                    this.foundTableData = res.datas
                }
            })
        },
        //当选择的参数值变时 查询列表
        tabelNameEnChange(value) {
            //判断动因表是否展示
            if(value.indexOf("CA_REASON_INF")){
               this.drverTypeFlag=true;
            }else{
                this.drverTypeFlag=false;
            }
            console.log(value, '金融工具表改变值')
            this.queryFoundColumnList(value)
        },
        //查询字段值
        queryFoundColumnList(value) {
            if (value == null && value == '') {
                return
            }
            let dataSearch = {
                isShow: '1',
                isTemplate: '0',
                tableNameEn: value
            }
            publicManage_dat.fundToolColumnQueryListCa(dataSearch).then(res => {
                if (res.code ==200) {
                    console.log(res.datas, '金融工具表数据')
                    this.foundTableData = res.datas;
                }
            })
        }
    }
}
</script>

<style lang="scss" scoped>
</style>